//
//  MyViewController.m
//  HAODE
//
//  Created by panquanReabam.com on 15/9/8.
//  Copyright (c) 2015年 reabam.com. All rights reserved.
//
#import "RDVTabBarController.h"
#import "MyViewController.h"
#import "HAODEsingleton.h"
#import "DailyTableViewCell.h"
#import "TheLoginViewController.h"

#import "SelectTheCertificationViewController.h"
#import "HttpRequest.h"
#import "RDVTabBarController.h"
#import "MJRefresh.h"

#import "huiyuandengjiViewController.h"
#import "orderListsViewController.h"
#import "ServiceListViewController.h"
#import "RefundListViewController.h"

#import "AboutUsViewController.h"
#import "UIButton+WebCache.h"
#import "SalesAnalysisDetailPageViewController.h"
#import "managementViewController.h"
#import "UMSocial.h"
#import "DiscoverHouseholdMyCollectViewController.h"

@interface MyViewController ()<UITableViewDataSource,UITableViewDelegate,UIScrollViewDelegate, UITextViewDelegate,UIImagePickerControllerDelegate,UIAlertViewDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UIActionSheetDelegate,UMSocialUIDelegate>

{
    MJRefreshHeaderView* _header;
    MJRefreshFooterView* _footer;
    NSArray *array;
    NSArray *array1;
    NSArray *array2;
    NSArray *array3;
    UIButton *noticeCountBtn;
    UIWebView *web;
    UILabel* name1;
    UIButton* name;
    HAODEsingleton* commdity;
    UIImageView *imageView ;
    UIView *headerView;
    UIButton* renzhenButton;
    NSDictionary *DataLine;
    UIButton *button;
    UIButton*TheMessageBtn;
    NSString *url;
    UILabel*userType;
    NSString* userAudit;
}
@property(nonatomic,strong)   NSString*shuoming;
@property(nonatomic,strong)   NSString*shareUrl;
@end

@implementation MyViewController
@synthesize alt = alt;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"我的";
        
    }
    return self;
}
-(void)renzhenButton:(UIButton *)sender{
    
    SelectTheCertificationViewController * Login=[[SelectTheCertificationViewController alloc]init];
    
    [self.navigationController pushViewController:Login animated:YES];
}
- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    
    
    
    self.navigationController.delegate = nil;
    
}
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    // 禁用 iOS7 返回手势
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    }
}

-(void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    
   
    [[self rdv_tabBarController] setTabBarHidden:NO];
    self.navigationController.navigationBarHidden=YES;
    [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
    self.navigationController.delegate = self;
    
    
    
    self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 0)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];

    [self jiazai];
    
    
}
-(void)jiazai{
    
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    
    NSString* StoreName = [user objectForKey:@"companyName"];
    NSString* UserName = [user objectForKey:@"userName"];
    self.title =@"";
    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setValue:Token forKey:@"tokenId"];
    
    [HttpRequest requestData:@"System/GetUserAuthStatus" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            NSLog(@"====%@",severDataDict.dataDict);
            
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
                
                url=[severDataDict.dataDict objectForKey:@"headImageUrl"];
                [imageView setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"logo_normalss.png"]];
                [user setObject:[severDataDict.dataDict objectForKey:@"headImageUrl"] forKey:@"headImageUrl"];
                [user setObject:[severDataDict.dataDict objectForKey:@"headImage"] forKey:@"headImage"];
                [user setObject:[severDataDict.dataDict objectForKey:@"sex"] forKey:@"sex"];
                [user setObject:[severDataDict.dataDict objectForKey:@"userName"]forKey:@"userName"];
                
                [user setObject:[NSString stringWithFormat:@"%@", [severDataDict.dataDict objectForKey:@"companyName"]]forKey:@"companyName"];
                [user setObject:[NSString stringWithFormat:@"%@",[severDataDict.dataDict objectForKey:@"userAudit"]] forKey:@"userAudit"];
                [user setObject:[NSString stringWithFormat:@"%@",[severDataDict.dataDict objectForKey:@"companyId"]] forKey:@"companyId"];
                [user setObject:[NSString stringWithFormat:@"%@", [severDataDict.dataDict objectForKey:@"userTypeName"]]  forKey:@"userTypeName"];
                [user setObject:[NSString stringWithFormat:@"%@", [severDataDict.dataDict objectForKey:@"userCode"]]  forKey:@"userCode"];
                [user synchronize];
                [renzhenButton removeFromSuperview];
                renzhenButton= [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-80, 170/2, 65, 24)];
                renzhenButton.titleLabel.font=[UIFont systemFontOfSize:13];
                renzhenButton.backgroundColor=luseColor;
                [headerView addSubview:renzhenButton];
                
                userAudit = [severDataDict.dataDict objectForKey:@"userAudit"];
                
                if (Token==nil) {
                    [name setTitle:@"未登录" forState:UIControlStateNormal];
                    [name addTarget:self action:@selector(add:) forControlEvents:UIControlEventTouchUpInside];
                }
                if (Token!=nil) {
                    
                    
                    
                    NSString *s2 =[NSString stringWithFormat:@"%@",  UserName];
                    UIFont *font2 = [UIFont systemFontOfSize:eighteenthORfifteenFot];
                    CGSize size2 = CGSizeMake(ScreenWidth-60, 2000);
                    CGSize labelsize2 = [s2 sizeWithFont:font2 constrainedToSize:size2 lineBreakMode:NSLineBreakByCharWrapping];
                    
                    
                    NSString *s =[NSString stringWithFormat:@"%@",  [severDataDict.dataDict objectForKey:@"userTypeName"]];
                    UIFont *font = [UIFont systemFontOfSize:eighteenthORfifteenFot];
                    CGSize size = CGSizeMake(ScreenWidth-60, 2000);
                    CGSize labelsize = [s sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping];
                    
                    name.frame=CGRectMake(200/2, 150/2, labelsize2.width, eighteenthORfifteenFot);
                    [name setTitle:UserName forState:UIControlStateNormal];
                    userType.frame= CGRectMake(name.right+5, 150/2, labelsize.width, eighteenthORfifteenFot);
                    userType .text=s ;
                    name1 .text=StoreName ;
                    
                    
                    
                    if ([userAudit isEqualToString:@"E"]) {
                        [self tableHeadView];
                        [renzhenButton removeFromSuperview];
                        renzhenButton= [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-80, 170/2, 65, 24)];
                        renzhenButton.titleLabel.font=[UIFont systemFontOfSize:13];
                        renzhenButton.backgroundColor=luseColor;
                        [renzhenButton setTitle:@"去认证" forState:UIControlStateNormal];
                        
                        [renzhenButton addTarget:self action:@selector(renzhenButton:) forControlEvents:UIControlEventTouchUpInside];
                    }
                    
                    
                    
                    
                    if ([userAudit isEqualToString:@"Y"]) {
                        
                        
                        if(commdity.Dicts==nil)
                            
                        {
                            [self tableHeadView];
                            
                        }else{
                            
                            
                        }
                        
                        [renzhenButton addTarget:self action:@selector(store:) forControlEvents:UIControlEventTouchUpInside];
                       renzhenButton.backgroundColor=[UIColor clearColor];
                        renzhenButton.frame=CGRectMake(ScreenWidth-30, 170/2, 8, 13);
                        [renzhenButton setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
                        
                        
                        
                        
                        NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
                        
                        NSString* userName = [user objectForKey:@"userName"];
                        
                        NSString* userType1 = [user objectForKey:@"userTypeName"];
                        
                        
                        
                        NSString *s2 =[NSString stringWithFormat:@"%@",  userName];
                        UIFont *font2 = [UIFont systemFontOfSize:18];
                        CGSize size2 = CGSizeMake(ScreenWidth-60, 2000);
                        CGSize labelsize2 = [s2 sizeWithFont:font2 constrainedToSize:size2 lineBreakMode:NSLineBreakByCharWrapping];
                        
                        
                        NSString *s =[NSString stringWithFormat:@"%@",  userType1];
                        UIFont *font = [UIFont systemFontOfSize:16];
                        CGSize size = CGSizeMake(ScreenWidth-60, 2000);
                        CGSize labelsize = [s sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping];
                        [name removeFromSuperview];
                        
                        [userType removeFromSuperview];
                        name=[[UIButton alloc]initWithFrame:CGRectMake(200/2, 145/2, labelsize2.width, 18)];
                        [name setTitle:userName forState:UIControlStateNormal];
                        name.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
                        [name setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                        name.titleLabel.font=[UIFont systemFontOfSize:18];
                        [headerView addSubview:name];
                        
                        userType=[[UILabel alloc]initWithFrame:CGRectMake(name.right+5, 146/2, labelsize.width, 16)];
                        userType .text=userType1 ;
                        userType.textColor=[UIColor whiteColor];
                        userType.textAlignment=NSTextAlignmentCenter;
                        userType.backgroundColor = [UIColor colorWithRed:190/255.0 green:168/255.0 blue:39/255.0 alpha:0.66];                     userType.font=[UIFont systemFontOfSize:12];
                        [headerView addSubview:userType];
                        
                        
                        UIButton*jiada=[[UIButton alloc]initWithFrame:CGRectMake(140, 0, ScreenWidth-140,130)];
                        [jiada addTarget:self action:@selector(store:) forControlEvents:UIControlEventTouchUpInside];
                        [headerView addSubview:jiada];
                        
                        
                    }
                    if ([userAudit isEqualToString:@"N"]) {
                        [self tableHeadView];
                        [renzhenButton removeFromSuperview];
                        renzhenButton= [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-80, 170/2, 65, 24)];
                        renzhenButton.titleLabel.font=[UIFont systemFontOfSize:13];
                        renzhenButton.backgroundColor=luseColor;
                        [renzhenButton setTitle:@"认证不通过" forState:UIControlStateNormal];
                        [renzhenButton addTarget:self action:@selector(renzhenButton:) forControlEvents:UIControlEventTouchUpInside];
                        
                    }
                    if ([userAudit isEqualToString:@"W"]) {
                        [self tableHeadView];
                        [renzhenButton removeFromSuperview];
                        renzhenButton= [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-80, 170/2, 65, 24)];
                        renzhenButton.titleLabel.font=[UIFont systemFontOfSize:13];
                        renzhenButton.backgroundColor=luseColor;
                        [headerView addSubview:renzhenButton];
                        [renzhenButton setTitle:@"认证中" forState:UIControlStateNormal];
                        //                          [renzhenButton addTarget:self action:@selector(renzhenButton:) forControlEvents:UIControlEventTouchUpInside];
                        
                        //                            name1.text =[severDataDict.dataDict objectForKey:@"companyName"];
                        
                    }
                    
                    
                    [headerView addSubview:renzhenButton];
                }else{
                    
                    
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                        
                        TheLoginViewController*detailViewController = [[TheLoginViewController alloc] init];
                        
                        [self.navigationController pushViewController:detailViewController animated:YES];
                        
                        
                    }

                    
                    
                    
                }
                
                
                
                
                
            }
            
            else{
                [Global hideProgressHUDInternal:self.view];
                
                
            }
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
            
            
            
        }
        
    }];
    
    
    
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self loadViewTabel];
    [self tableHeadView];
    [self addFooter];
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setValue:Token forKey:@"tokenId"];
    [params setValue:@"member" forKey:@"uploadType"];
    
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    [HttpRequest requestData:@"Common/GetUpyunFormParams" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                NSLog(@"%@",severDataDict.dataDict);
                
                NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
                NSString*policy=[severDataDict.dataDict objectForKey:@"policy"];
                NSString*signature=[severDataDict.dataDict objectForKey:@"signature"];
                NSString*action=[severDataDict.dataDict objectForKey:@"action"];
                [user setObject:signature forKey:@"signature"];
                [user setObject:policy forKey:@"policy"];
                [user setObject:action forKey:@"action"];
                [user synchronize];
                
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                // [Global showTextHud:requestResultStr view:self.view];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
}
- (void)loadViewTabel{
    
    //    NSArray *arr1 = @[@"我的报价",@"wodebaojia"];
    //    NSArray *arr2 = @[@"我的经营数据",@"jingyingshuju"];
    //
    //    NSArray *arr3 = @[@"物业优惠券",@"youhuiquan"];
    NSArray *arr4 = @[@"我的业绩",@"wodeyeji"];
    
    //
    //    NSArray *arr5 = @[@"我的话题",@"wodehauti"];
    NSArray *arr6 = @[@"我的收藏",@"wodeshoucang"];
    //
    //
    //
    NSArray *arr7 = @[@"功能介绍",@"gongnengjieshao"];
    NSArray *arr8 = @[@"邀请好友",@"yaoqinghaoyou"];
    
    //
    
    array = @[arr4,arr6];
    array1 = @[arr8,arr7];
    //array2 = @[arr5,arr6];
    //array3 = @[arr7,arr8];
    
    
}


- (void)tableHeadView
{
    
   [headerView removeFromSuperview];
    headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth,322/2)];
    UIImageView* heardimage=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 160)];
    heardimage.image=[UIImage imageNamed:@"wodebeijing"];
    [headerView addSubview:heardimage];
    
    UIImageView* heardimage1=[[UIImageView alloc]initWithFrame:CGRectMake(18, 110/2, 145/2, 145/2)];
    heardimage1.image=[UIImage imageNamed:@"logoyuanhuansss"];
    [headerView addSubview:heardimage1];
    
    imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 132.5/2, 132.5/2)];
    imageView.layer.masksToBounds = YES;
    imageView.layer.cornerRadius = 132.5/2/2;
    
    imageView.center= heardimage1.center;
    imageView.contentMode = UIViewContentModeScaleToFill;
    [imageView setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"touxiang_weidenglu"]];
    
    imageView.layer.borderColor = [UIColor whiteColor].CGColor;
    imageView.layer.borderWidth = 0;
    [headerView addSubview:imageView];
    
    
    
    
    commdity=[HAODEsingleton shared];
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    
    NSString* userName = [user objectForKey:@"userName"];
    NSString* StoreName = [user objectForKey:@"companyName"];
    NSString* userType1 = [user objectForKey:@"userTypeName"];
    
    
    
    NSString *s2 =[NSString stringWithFormat:@"%@",  userName];
    UIFont *font2 = [UIFont systemFontOfSize:18];
    CGSize size2 = CGSizeMake(ScreenWidth-60, 2000);
    CGSize labelsize2 = [s2 sizeWithFont:font2 constrainedToSize:size2 lineBreakMode:NSLineBreakByCharWrapping];
    
    
    NSString *s =[NSString stringWithFormat:@"%@",  userType1];
    UIFont *font = [UIFont systemFontOfSize:16];
    CGSize size = CGSizeMake(ScreenWidth-60, 2000);
    CGSize labelsize = [s sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping];
    
    name=[[UIButton alloc]initWithFrame:CGRectMake(200/2, 145/2, labelsize2.width, 18)];
    [name setTitle:userName forState:UIControlStateNormal];
    name.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
    [name setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    name.titleLabel.font=[UIFont systemFontOfSize:18];
    [headerView addSubview:name];
    
    userType=[[UILabel alloc]initWithFrame:CGRectMake(name.right+5, 148/2, labelsize.width, 16)];
    userType .text=userType1 ;
    userType.textColor=[UIColor whiteColor];
    userType.textAlignment=NSTextAlignmentCenter;
    userType.backgroundColor = [UIColor colorWithRed:190/255.0 green:168/255.0 blue:39/255.0 alpha:0.66];                     userType.font=[UIFont systemFontOfSize:12];
    [headerView addSubview:userType];
    
    
    
    name1=[[UILabel alloc]initWithFrame:CGRectMake(200/2, 196/2, 200, 14)];
    name1 .text=StoreName ;
    name1.textColor=[UIColor whiteColor];
    name1.font=[UIFont systemFontOfSize:14];
    name1.numberOfLines=0;
    [headerView addSubview:name1];
    
    UIView*toumingview=[[UIView alloc]initWithFrame:CGRectMake(0, 160, ScreenWidth, 50)];
    toumingview.backgroundColor=[UIColor colorWithRed:255/255.0 green:204/255.0 blue:0/255.0 alpha:1.0];
//    toumingview.alpha=0.28;
    //      [headerView addSubview:toumingview];
    
    [self add];
    
    
    _table.frame=CGRectMake(0, -20, ScreenWidth, ScreenHeight-64-49);
    
    self.table.tableHeaderView = headerView;
    
    
    
    NSString* Token = [user objectForKey:@"tokenId"];
    
    
    
    if (Token==nil) {
        
    }else{
        
        
        
        
        UIView * tableFooterViews=[[UIView alloc]initWithFrame:CGRectMake(0, -25, ScreenWidth, 200)];
        tableFooterViews.backgroundColor=zuiqianhuicolor;
        UIView*huiseview=[[UIView alloc]initWithFrame:CGRectMake(0,20, ScreenWidth, 50)];
        huiseview.backgroundColor=[UIColor whiteColor];
        huiseview.layer.borderWidth = 0.3;
        huiseview.layer.borderColor = qianhuicolor.CGColor;
        [tableFooterViews addSubview:huiseview];
        UIButton*tuichu=[[UIButton alloc]init];
        tuichu.backgroundColor=[UIColor clearColor];
        [tuichu setTitle:@"退出登陆" forState:UIControlStateNormal];
        tuichu. titleLabel.font=[UIFont systemFontOfSize:16];
        [tuichu setTitleColor:shenhongsecolor forState:UIControlStateNormal];
        tuichu.frame=CGRectMake(0, 0, ScreenWidth, 50);
        [tuichu addTarget:self action:@selector(tuichu:) forControlEvents:UIControlEventTouchUpInside];
        [huiseview addSubview:tuichu];
        self.table.tableFooterView = tableFooterViews;
        
    }
    
    self.table.backgroundColor=zuiqianhuicolor;
    
    _table.separatorStyle=UITableViewCellSeparatorStyleNone;
}




-(void)add{
    
    
    
    NSArray *buttonContent = @[@[@"会员",@"订单",@"售后服务",@"退货"],
                               @[@"344",@"44",@"44",@"200"]];
    NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
    NSString* tokenId = [user1 objectForKey:@"tokenId"];
    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setValue:tokenId forKey:@"tokenId"];
    NSLog(@"-----%@",params);
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:20 view:self.view];
    [HttpRequest requestData:@"UserCenter/DataInfo" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            NSLog(@"-----%@",severDataDict.dataDict);
            commdity.Dicts=severDataDict.dataDict;
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                
                DataLine=[[NSDictionary alloc]init];
                DataLine=severDataDict.dataDict ;
                
                
                for (int i = 0;  i<4; i++) {
                    button = [[UIButton alloc]init];
                    button.frame = CGRectMake(ScreenWidth*i/4, 150, headerView.width/4, 50);
                    
                    
                    if (i==0) {
                        [button setTitle:[NSString stringWithFormat:@"%@",[DataLine objectForKey:@"memberCount"]] forState:UIControlStateNormal];
                        
                    }
                    if (i==1) {
                        [button setTitle:[NSString stringWithFormat:@"%@",[DataLine objectForKey:@"orderCount"]] forState:UIControlStateNormal];
                        
                    }
                    if (i==2) {
                        [button setTitle:[NSString stringWithFormat:@"%@",[DataLine objectForKey:@"afterSaleCount"]] forState:UIControlStateNormal];
                        
                    }
                    if (i==3) {
                        [button setTitle:[NSString stringWithFormat:@"%@",[DataLine objectForKey:@"returnSaleCount"]] forState:UIControlStateNormal];
                        
                    }
                    
                    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
                    button.tag = i+1;
                    button.titleLabel.font=[UIFont systemFontOfSize:15];
                    //                    [headerView addSubview:button];
                    
                    
                    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth*i/4, 150+30, button.width, 30)];
                    [label setTextAlignment:NSTextAlignmentCenter];
                    label.font = [UIFont systemFontOfSize:15];
                    label.text = [NSString stringWithFormat:@"%@",[buttonContent[0] objectAtIndex:i]];
                    label.textColor=[UIColor whiteColor];
                    //                   [headerView addSubview:label];
                    
                    
                }
                
                
            }else{
                
                [Global hideProgressHUDInternal:self.view];
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                    
                    TheLoginViewController*detailViewController = [[TheLoginViewController alloc] init];
                    
                    [self.navigationController pushViewController:detailViewController animated:YES];
                    
                    
                }
                
                
                
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
    
    
}
-(void)tuichu:(UIButton*)sender{
    
    UIAlertView* alts = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"是否确认注销？" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
    [alts show];
    
    
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    
    if (buttonIndex == 1) {
        
        commdity.shouye=@"shouye";
        // [APService setAlias:@"" callbackSelector:nil object:self];
        
        NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
        [user setObject:@"tuichu" forKey:@"tokenId"];
        
        [user synchronize];
        
        TheLoginViewController* Login=[[TheLoginViewController alloc]init];
        
        [self.navigationController pushViewController:Login animated:YES];
        
    }
    
}


-(void)buttonAction:(UIButton*)sender{
    
    if (sender.tag==1) {
        huiyuandengjiViewController * Login=[[huiyuandengjiViewController alloc]init];
        //
        [self.navigationController pushViewController:Login animated:YES];
    }
    if (sender.tag==2) {
        orderListsViewController * Login=[[orderListsViewController alloc]init];
        //
        [self.navigationController pushViewController:Login animated:YES];
    }
    if (sender.tag==3) {
        ServiceListViewController * Login=[[ServiceListViewController alloc]init];
        //
        [self.navigationController pushViewController:Login animated:YES];
    }
    if (sender.tag==4) {
        RefundListViewController * Login=[[RefundListViewController alloc]init];
        //
        [self.navigationController pushViewController:Login animated:YES];
    }
    
}
//上拉刷新
- (void)addFooter
{
    
    //
    
    
    
    MJRefreshHeaderView* footer = [MJRefreshHeaderView header];
    footer.scrollView = _table;
    footer.beginRefreshingBlock = ^(MJRefreshBaseView* refreshView)
    {
        
        
        [self loadViewTabel];
        [self tableHeadView];
        [self jiazai];
        
        [self performSelector:@selector(doneWithView:) withObject:refreshView afterDelay:3.0f];
        NSLog(@"%@--->正在刷新", refreshView.class);
    };
    
}
- (void)doneWithView:(MJRefreshBaseView *)refreshView
{
    [_table reloadData];
    [refreshView endRefreshing];
}


-(void)store:(UIButton*)sender{
    
    managementViewController * Login=[[managementViewController alloc]init];
    commdity.gengxin=@"123";
    [self.navigationController pushViewController:Login animated:YES];
    
    
}
-(void)store{
    
    managementViewController * Login=[[managementViewController alloc]init];
    [self.navigationController pushViewController:Login animated:YES];
    
    
}
#pragma mark--TableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2 ;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return array.count;
    }if (section == 1) {
        return array1.count;
    }
    return array1.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    DailyTableViewCell* cell = (DailyTableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        NSArray* nib = [[NSBundle mainBundle] loadNibNamed:@"DailyTableViewCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }
  
   
//  cell.accessoryView=jiantou;
    
    cell.textLabel.font=[UIFont systemFontOfSize:15];
    cell.textLabel.textColor=[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1]
    ;
    if (indexPath.section == 0) {
        UIButton*jiantou = [[UIButton alloc]init];
        jiantou.frame = CGRectMake(ScreenWidth-30,17.5, 8, 13);
        [jiantou setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
        [cell.contentView addSubview:jiantou];
        cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",[[array objectAtIndex:indexPath.row] objectAtIndex:1]]];
        cell.textLabel.text = [[array objectAtIndex:indexPath.row] objectAtIndex:0];
        
        if (indexPath.row==0) {
            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.35)];
            lineLabel1.backgroundColor=qianhuicolor;
            [cell.contentView addSubview:lineLabel1];
            
        }
        
        if ([[array objectAtIndex:indexPath.row] count ] !=indexPath.row+1) {
            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(50, 50-0.35, ScreenWidth-65, 0.3)];
            lineLabel1.backgroundColor=qianhuicolor;
            [cell.contentView addSubview:lineLabel1];
            
        }
        
        if ([[array objectAtIndex:indexPath.row] count ] ==indexPath.row+1) {
            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 50-0.35, ScreenWidth, 0.35)];
            lineLabel1.backgroundColor=qianhuicolor;
            [cell.contentView addSubview:lineLabel1];
            
        }

    }
    
    
    if (indexPath.section == 1) {
        UIButton*jiantou = [[UIButton alloc]init];
        jiantou.frame = CGRectMake(ScreenWidth-30,17.5, 8, 13);
        [jiantou setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
        [cell.contentView addSubview:jiantou];
        cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",[[array1 objectAtIndex:indexPath.row] objectAtIndex:1]]];
        cell.textLabel.text = [[array1 objectAtIndex:indexPath.row] objectAtIndex:0];
        
        if (indexPath.row==0) {
            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.3)];
            lineLabel1.backgroundColor=qianhuicolor;
            [cell.contentView addSubview:lineLabel1];
            
        }

        if ([[array1 objectAtIndex:indexPath.row] count ]!=indexPath.row+1) {
            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(50, 50-0.35, ScreenWidth-65, 0.3)];
            lineLabel1.backgroundColor=qianhuicolor;
            [cell.contentView addSubview:lineLabel1];
            
        }
        
//        if ([[array1 objectAtIndex:indexPath.row] count ] ==indexPath.row+1) {
//            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 50-0.35, ScreenWidth, 0.3)];
//            lineLabel1.backgroundColor=qianhuicolor;
//            [cell.contentView addSubview:lineLabel1];
//            
//        }
 
    }
    
    
    
    
    
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    DailyTableViewCell *cell =(DailyTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
    
    if ([cell.textLabel.text isEqualToString:@"系统设置"]) {
        
//        SystemSettingsViewController * Login=[[SystemSettingsViewController alloc]init];
//        
//        [self.navigationController pushViewController:Login animated:YES];
        
    }
    if ([cell.textLabel.text isEqualToString:@"关于我们"]) {
        AboutUsViewController * Login=[[AboutUsViewController alloc]init];
        
        [self.navigationController pushViewController:Login animated:YES];
        
        
    }
    
    
    
//    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
//    
//    userAudit = [user objectForKey:@"userAudit"];
//    
//    
//    
//    
//    if ([cell.textLabel.text isEqualToString:@"我的经营数据"]) {
//        if ([userAudit isEqualToString:@"Y"]) {
//            SalesAnalysisDetailPageViewController*detailViewController = [[SalesAnalysisDetailPageViewController alloc] init];
//            
//            [self.navigationController pushViewController:detailViewController animated:YES];
//        }else{
//            [self renzhensat ];
//        }
//        
//    }
//    else if ([cell.textLabel.text isEqualToString:@"物业优惠券"]) {
//        if ([userAudit isEqualToString:@"Y"]) {
//            
//            UserCenterCouponListViewController*detailViewController = [[UserCenterCouponListViewController alloc] init];
//            
//            [self.navigationController pushViewController:detailViewController animated:YES];
//        }else{
//            [self renzhensat ];
//        }
//        
//    }else if ([cell.textLabel.text isEqualToString:@"我关注的服务"]) {
//        if ([userAudit isEqualToString:@"Y"]) {
//            
//            ConvenienceConcernListViewController*detailViewController = [[ConvenienceConcernListViewController alloc] init];
//            
//            [self.navigationController pushViewController:detailViewController animated:YES];
//        }else{
//            [self renzhensat ];
//        }
//        
//    }else if ([cell.textLabel.text isEqualToString:@"我的话题"]) {
//        if ([userAudit isEqualToString:@"Y"]) {
//            
//            DiscoverMCircleMyViewController*detailViewController = [[DiscoverMCircleMyViewController alloc] init];
//            
//            [self.navigationController pushViewController:detailViewController animated:YES];
//        }else{
//            [self renzhensat ];
//        }
//        
//    }else if ([cell.textLabel.text isEqualToString:@"我的收藏"]) {
        if ([userAudit isEqualToString:@"Y"]) {
            
            DiscoverHouseholdMyCollectViewController*detailViewController = [[DiscoverHouseholdMyCollectViewController alloc] init];
            
            [self.navigationController pushViewController:detailViewController animated:YES];
            
        }else{
            [self renzhensat ];
        }
        
    
}
-(void)renzhensat{
    
    if ([userAudit isEqualToString:@"E"]) {
        SelectTheCertificationViewController * Login=[[SelectTheCertificationViewController alloc]init];
        
        [self.navigationController pushViewController:Login animated:YES];
    }
    if ([userAudit isEqualToString:@"N"]) {
        SelectTheCertificationViewController * Login=[[SelectTheCertificationViewController alloc]init];
        
        [self.navigationController pushViewController:Login animated:YES];
    }
    if ([userAudit isEqualToString:@"W"]) {
        [self showAlertMessage:@"账号信息审核中，请耐心等待"];
    }
    
    
}
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return  50;
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
//    if (section==1) {
//        return 1;
//    }
    return 1;
}
-(void)add:(UIButton *)sender{
    
    TheLoginViewController* Login=[[TheLoginViewController alloc]init];
    
    [self.navigationController pushViewController:Login animated:YES];
    
    
    
}


- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}

- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}

@end
